import { BasicDrawer, useDrawerInner } from "@/components/Drawer";
import { BasicForm, FormSchema, useForm } from "@/components/Form";
// import { Select } from "antd";
import { useTranslation } from "react-i18next";
// const { Option } = Select;
let reload: Function;
let addFn: Function;
const index = (props: { register: Fn }) => {
	const { t } = useTranslation();
	const schemas: FormSchema[] = [
		{
			label: t("felix_ui.patient_id"),
			field: "patient_id",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.full_name"),
			field: "full_name", //姓名
			component: "Input",
			colProps: { span: 12 }
		},
		// {
		// 	label: t("felix_ui.date_of_birth"),
		// 	field: "date_of_birth",
		// 	component: "Input",
		// 	colProps: { span: 12 }
		// },
		{
			label: t("felix_ui.birthday"),
			field: "birthday", //生日
			component: "DatePicker",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.gender"),
			field: "gender",
			component: "Select",
			componentProps: {
				options: [
					{ label: "Nam", value: "Nam" },
					{ label: "Phụ nữ", value: "Phụ nữ" }
				]
			},
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.occupation"),
			field: "occupation",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.citizen_id"),
			field: "citizen_id",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.pat_address"),
			field: "pat_address",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.workplace"),
			field: "workplace",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.phone_numb"),
			field: "phone_numb",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.gruop_id"),
			field: "gruop_id",
			component: "Select",
			componentProps: {
				options: [
					{ label: "1", value: "1" },
					{ label: "2", value: "2" }
				]
			},
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.dept_name"),
			field: "dept_name",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.vac_dose1"),
			field: "vac_dose1",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.vac_date_dose1"),
			field: "vac_date_dose1",
			component: "Select",
			componentProps: {
				options: [
					{ label: "1", value: "1" },
					{ label: "2", value: "2" }
				]
			},
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.manufacturer_id"),
			field: "manufacturer_id1",
			component: "Select",
			componentProps: {
				options: [
					{ label: "1", value: "1" },
					{ label: "2", value: "2" }
				]
			},
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.batch_numb"),
			field: "batch_numb1",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.vac_unit"),
			field: "vac_unit1",
			component: "Input",
			componentProps: {
				// addonAfter: (
				// 	<Select style={{ width: 70 }}>
				// 		<Option value="86">+86</Option>
				// 		<Option value="87">+87</Option>
				// 	</Select>
				// )
			},
			labelWidth: 140,
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.vac_dose2"),
			field: "vac_dose2",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.vac_date_dose2" + "111111"),
			field: "vac_date_dose2",
			component: "Select",
			componentProps: {
				options: [
					{ label: "1", value: "1" },
					{ label: "2", value: "2" }
				]
			},
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.manufacturer_id"),
			field: "manufacturer_id2",
			component: "Select",
			componentProps: {
				options: [
					{ label: "1", value: "1" },
					{ label: "2", value: "2" }
				]
			},
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.batch_numb"),
			field: "batch_numb2",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.vac_unit"),
			field: "vac_unit2",
			component: "Input",
			componentProps: {
				// addonAfter: (
				// 	<Select style={{ width: 70 }}>
				// 		<Option value="86">+86</Option>
				// 		<Option value="87">+87</Option>
				// 	</Select>
				// )
			},
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.vac_dose3"),
			field: "vac_dose3",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.manufacturer_id"),
			field: "manufacturer_id3",
			component: "Select",
			componentProps: {
				options: [
					{ label: "1", value: "1" },
					{ label: "2", value: "2" }
				]
			},
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.batch_numb"),
			field: "batch_numb3",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.vac_unit"),
			field: "vac_unit3",
			component: "Input",
			componentProps: {
				// addonAfter: (
				// 	<Select style={{ width: 70 }}>
				// 		<Option value="86">+86</Option>
				// 		<Option value="87">+87</Option>
				// 	</Select>
				// )
			},
			labelWidth: 140,
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.vac_reason"),
			field: "vac_reason",
			component: "Input",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.date_from"),
			field: "date_from",
			component: "DatePicker",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.date_to"),
			field: "date_to",
			component: "DatePicker",
			colProps: { span: 12 }
		},
		{
			label: t("felix_ui.hour"),
			field: "hour",
			component: "DatePicker",
			colProps: { span: 12 }
		}
	];
	const [registerDrawer, { closeDrawer }] = useDrawerInner(props.register, data => {
		console.log("打开Drawer", data);
		reload = data.reload;
		addFn = data.addFn;
	});
	const [register, { getFieldsValue }] = useForm({
		schemas,
		labelWidth: 180
	});
	const handleSubmit = async () => {
		const res = await getFieldsValue();
		addFn(res);
		closeDrawer();
		reload();
	};
	return (
		<BasicDrawer showFooter={true} size="large" {...props} register={registerDrawer} ok={handleSubmit}>
			<BasicForm register={register}></BasicForm>
		</BasicDrawer>
	);
};
export default index;
